<template>
    <div class="deep-seek">
        DEEPSEEK对话
        <el-input type="textarea" v-model="content" placeholder="请输入内容" :rows="5"></el-input>
        <el-button type="primary" class="mar-top-20" @click="sendBtn">发送</el-button>
    </div>
</template>
<script setup>
import { ref } from 'vue'
import axios from 'axios';
const content = ref('')
const callDeepSeekAPI = (data) => {
    const apiKey = 'sk-7d053ff6301e4c84b2f1b2a0779b2784';
    const apiUrl = '/api';
    try {
        const response = axios.post(apiUrl, data, {
            headers: {
                'Authorization': `Bearer ${apiKey}`,
                'Content-Type': 'application/json'
            }
        });
        return response.data;
    } catch (error) {
        console.error('Error calling DeepSeek API:', error);
        throw error;
    }
}
const sendBtn = () => {
    console.log(content.value)
    const data = {
        messages: [{ role: "system", content: content.value }],
        model: "deepseek-chat",
    }
    callDeepSeekAPI(data).then(response => {
        console.log(response);
    }).catch(error => {
        console.error(error);
    });
}



</script>
